package com.nexus.all.controller;

import com.nexus.all.dto.NoteWordQueryDTO;
import com.nexus.all.service.NoteService;
import com.nexus.all.service.NoteWordService;
import com.nexus.bean.annotation.PassLogin;
import com.nexus.bean.result.Result;
import com.nexus.web.controller.CommonController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RequestMapping("/noteWord")
@RestController
@Api(tags = "笔记关键词接口管理")
public class NoteWordController extends CommonController {
    private final NoteService noteService;
    private final NoteWordService noteWordService;

    public NoteWordController(NoteService noteService, NoteWordService noteWordService) {
        this.noteService = noteService;
        this.noteWordService = noteWordService;
    }

    @ApiOperation(value = "初始化笔记关键字", notes = "初始化笔记关键字")
    @GetMapping("/initNoteWord")
    @PassLogin
    public Result initNoteWord() {
        noteService.initNoteWord();
        return Result.newSuccess();
    }

    @ApiOperation(value = "分页查询笔记关键词", notes = "分页查询笔记关键词")
    @PostMapping("/queryNoteWord")
    @PassLogin
    public Result<List<String>> queryNoteWord(@RequestBody NoteWordQueryDTO dto) {
        return Result.newSuccess(noteWordService.queryNoteWord(dto));
    }
}
